﻿using System;
using System.Collections.Generic;
using UnityEngine;

public class OptionGameOfCamera : MonoBehaviour {
	// === Unity ======================================================================================================
	public UILabel Label;
	public UIPopupList PopupList;

	private void Awake() {
		if (Label == null) {
			throw new ArgumentException("Label is null");
		}

		if (PopupList == null) {
			throw new ArgumentException("PopupList is null");
		}
	}

	private void Start() {
		PopupList.items = new List<string> { CAMERA2D, CAMERA3D };
		PopupList.value = SettingsGameModel.IsCamera2D ? CAMERA2D : CAMERA3D;
		EventDelegate.Add(PopupList.onChange, PopupListChangeCallback);
	}

	// === Private ====================================================================================================
	private const string CAMERA2D = "Camera 2D";
	private const string CAMERA3D = "Camera 3D";

	private void PopupListChangeCallback() {
		if (PopupList.value.Equals(CAMERA2D)) {
			SettingsGameModel.IsCamera2D = true;
		}

		if (PopupList.value.Equals(CAMERA3D)) {
			SettingsGameModel.IsCamera2D = false;
		}
	}
}